目前只能在WinXP 32bit正常编译,Windows 7 32bit及64位中好像问题比较多,目前本人还未测试通过。
安装基本环境
Open a Windows SDK (7.0, 7.1 or later) command prompt. Ensure that the following tools can be found in the path:
- Perl version 5.12 or later [http://www.activestate.com/activeperl/]
- Python version 2.7 or later [http://www.python.org/ftp/python/2.7.6/python-2.7.6.msi,http://www.activestate.com/activepython/]
- Ruby version 1.9.3 or later [http://rubyinstaller.org/](用不到,如果要编译Webkit会使用,但是目前无法静态编译Webkit)
- MinGW环境 “Qt 5.1.1 for Windows 32-bit (MinGW 4.8, OpenGL, 666 MB)”在http://qt-project.org/downloads下载,也可以使用http://sourceforge.net/projects/mingwbuilds/files/mingw-builds-install/
Qt源码下载:http://download.qt-project.org/official_releases/qt/5.1/5.1.1/single/qt-everywhere-opensource-src-5.1.1.zip
SET PATH=C:\Python27;%PATH% SET PATH=C:\Perl\bin;%PATH% SET PATH=C:\Qt\Qt5.1.1\Tools\mingw48_32\bin;%PATH% SET QTSRC=C:\Users\jilili\Project\qt\qt-everywhere-opensource-src-5.1.1 SET INSTDIR=C:\Qt\Qt5.1.1\5.1.1\mingw48_32-static cd %QTSRC%
配置项目
修改qmake.conf,否则编译后的应用还要依赖libgcc_s_dw2-1.dll、libstdc++-6.dll、libwinpthread-1.dll文件。 %QTSRC%\qtbase\mkspecs\win32-g++\qmake.conf
QMAKE_LFLAGS = 修改为: QMAKE_LFLAGS = -static
QMAKE_LFLAGS_DLL = -shared 修改为: QMAKE_LFLAGS_DLL = -static
configure过程会生成qmake.exe及相关的文件。
configure -debug-and-release -static -opensource -confirm-license -platform win32-g++ -prefix %INSTDIR% -nomake tests -nomake examples -skip qtwebkit -mp -no-icu -no-c++11 -opengl desktop -qt-zlib -qt-libpng -qt-libjpeg -no-compile-examples
编译和安装
mingw32-make mingw32-make install